<template>
	<view class="CertifiedStore">
		<view style="padding-top: 88rpx;">
			<view class="NavigationBox">
				
				<view class="inputBox">
					<u-search placeholder="请输入要绑定的门店" v-model="keyword" :show-action="true" action-text="取消" :animation="true" @search="searchBtn"></u-search>
				</view>
			</view>
			<view class="CertifiedStoreBox">
				<view class="CertifiedStoreList">
					<view class="CertifiedStoreItem" v-for="(item,index) in list" :key="index" :data-index="index" :data-id="item.id" @click="toReal">
						<view class="CertifiedStoreNameBox">
							<view class="CertifiedStoreImage">
								<image src="/static/mine/shop.png" mode=""></image>
							</view>
							<view class="CertifiedStoreName">{{item.name}}</view>
						</view>
						<view class="address">{{item.detailed_address}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword:'',
				list:[],
				moreFlag:false,
				page:1
			}
		},
		onLoad() {
      // #ifdef APP-PLUS
      var args = plus.runtime.arguments;
      if(args){
        app.$vm.setShareDetail(args);
      }
      // #endif
			this.getList();
		},
		onReachBottom() {
			console.log(123)
			if(!this.moreFlag){
				return false;
			}
			this.moreFlag = false;
			this.page = this.page + 1;
			this.getList();
		},
		methods: {
			// #ifdef APP-PLUS
			// 动态设置原生导航栏按钮值
			// setStyle(index, text) {
			// 	// console.log(index,text);
			// 	let pages = getCurrentPages();
			// 	let page = pages[pages.length - 1];
			// 	if (text.length > 3) {
			// 		text = text.substr(index, 3) + '...';
			// 	}
			// 	let currentWebview = page.$getAppWebview();
			// 	let titleNView = currentWebview.getStyle().titleNView;
			// 	// 添加文字过长截取为3个字符，请根据自己业务需求更改
			// 	titleNView.buttons[index].text = text;
			// 	currentWebview.setStyle({
			// 		titleNView: titleNView
			// 	});
			// 	uni.showToast({
			// 		title:`当前位置为${text}`,
			// 		icon:"none"
			// 	})
			// },
			// #endif
			toReal(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let index = e.target.dataset.index || e.currentTarget.dataset.index;
				uni.showLoading({
					title:"加载中..."
				})
				this.$u.api.shopAuthenticationDetails({shop_id:id}).then(res=>{
					console.log(res)
					// this.authInfo = res.data.details;
					if(res.data.details){
						res.data.details.name = this.list[index].name;
						res.data.details.address = this.list[index].detailed_address;
					}else{
						res.data.details = {};
						res.data.details.name = this.list[index].name;
						res.data.details.address = this.list[index].detailed_address;
					}
					uni.setStorageSync("authInfo",res.data.details)
					uni.hideLoading();
					uni.navigateTo({
						url:"/pages/pagefive/pages/storeReal/storeReal?id="+id
					})
				})
			},
			//搜索
			searchBtn(){
				// alert(this.keyword)
				this.page = 1;
				this.getList();
			},
			getList(){
				let obj = {};
				obj.page = this.page;
				obj.data = {};
				obj.data.is_authentication = 0;
				if(this.keyword.trim() != ""){
					obj.data.search = this.keyword;
				}
				this.$u.api.shopList(obj).then(res=>{
					console.log(res)
					if(this.page == 1){
						this.list = res.data.list.data;
					}else{
						this.list = this.list.concat(res.data.list.data);
					}
					if(res.data.list.last_page > this.page){
						this.moreFlag = true;
					}else{
						this.moreFlag = false;
					}
				})
			}
		}
	}
</script>

<style scoped lang="less">
.CertifiedStore{
	background-color: #F3F3F3;
	min-height: 100vh;
	// padding-top: 88upx;
	overflow: auto;
	.NavigationBox{
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		width: 750upx;
		height: 88upx;
		display: flex;
		align-items: center;
		padding: 0 24upx;
		background-color: #FFFFFF;
		.locationBox{
			display: flex;
			align-items: center;
			.locationName{
				font-size: 24upx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
				margin-left: 32upx;
				// margin-right: 32upx;
			}
		}
		.inputBox{
			flex: 1;
		}
	}
	.CertifiedStoreBox{
		margin-top: 16upx;
		.CertifiedStoreList{
			width: 750upx;
			background: #FFFFFF;
			opacity: 1;
			.CertifiedStoreItem{
				padding: 24upx;
				border-bottom: 2upx solid #EDEDED;
				.CertifiedStoreNameBox{
					display: flex;
					align-items: center;
					.CertifiedStoreImage{
						width: 24upx;
						height: 24upx;
						display: flex;
						image{
							width: 100%;
							height: 100%;
						}
					}
					.CertifiedStoreName{
						font-size: 24upx;
						color: #333333;
						font-weight: 400;
						margin-left: 8upx;
					}
				}
				.address{
					font-size: 20upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #D0D0D0;
					margin-top: 16upx;
					margin-left: 32upx;
				}
			}
		}
	}
}
</style>
